<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>限时秒杀案例</title>
</head>
<body>
  <span id="a"></span>
  <span id="b"></span>
  <span id="c"></span>
  <span id="d"></span>
  <script>
    let times = new Date('2024-12-30 12:00').getTime()
    console.log(times);
    let timer = setInterval(arr, 1000)
    function arr() {
      let date = new Date()
      let now = parseInt((times - date.getTime()) / 1000)
      if (times > date) {
        a = parseInt(now / 86400)
        b = parseInt((now / 3600) % 24)
        c = parseInt((now / 60) % 60)
        d = parseInt(now % 60)
      } else {
        clearInterval(timer)
        a = b = c = d = '00'
      }
      document.getElementById('a').innerHTML = a + '天'
      document.getElementById('b').innerHTML = b + '时'
      document.getElementById('c').innerHTML = c + '分'
      document.getElementById('d').innerHTML = d + '秒'
    }
  </script>
</body>
</html>